package model

import (
	"context"

	"gorm.io/gorm"
)

type CommentLike struct {
	gorm.Model
	CommentIndexId int
	UserId         int
	LikeAction     int `gorm:"column:like_action;check:like_action IN (0,1)"` // 修改此处
}

// 增加点赞计数方法
func (m *defaultCommentModel) IncrementLikeCount(ctx context.Context, id uint, count int) error {
	return m.db.WithContext(ctx).Model(&CommentIndex{}).
		Where("id = ?", id).
		UpdateColumn("like_count", gorm.Expr("like_count + ?", count)).
		Error
}
